package com.sweet.fourtimeoa.controller;

import com.sweet.fourtimeoa.pojo.dto.*;
import com.sweet.fourtimeoa.pojo.entity.*;
import com.sweet.fourtimeoa.pojo.vo.*;
import com.sweet.fourtimeoa.service.DesktopService;
import com.sweet.fourtimeoa.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * 我的桌面
 */
@Slf4j
@Tag(name = "我的桌面")
@RestController
@RequestMapping("/oa/desktop")
@CrossOrigin(origins = "*")
public class DesktopController {

    @Autowired
    private DesktopService desktopService;



    @Operation(summary = "待处理任务-请假申请分页查询")
    @PostMapping("/queryLeaveApplicationsAndUsersList")
    public Result queryLeaveApplicationsAndUsersList(@RequestBody PageDto<LeaveApplicationsAndUsersDto> pageDto) {
        System.out.println(pageDto.getData());
        PageVo<LeaveApplicationsAndUsersVo> leaveApplicationsAndUsersVoPageVo = desktopService.queryLeaveApplicationsAndUsersList(pageDto);
        return Result.success(leaveApplicationsAndUsersVoPageVo);
    }
    @Operation(summary = "待处理任务-出差申请分页查询")
    @PostMapping("/queryTravelApplicationsAndUsersList")
    public Result queryTravelApplicationsAndUsersList(@RequestBody PageDto<TravelApplicationsAndUsersDto> pageDto) {
        System.out.println(pageDto.getData());
        PageVo<TravelApplicationsAndUsers> travelApplicationsAndUsersPageVo = desktopService.queryTravelApplicationsAndUsers(pageDto);
        return Result.success(travelApplicationsAndUsersPageVo);
    }
    @Operation(summary = "待处理任务-收入证明申请分页查询")
    @PostMapping("/queryIncomeProofApplicationsAndUsersList")
    public Result queryIncomeProofApplicationsAndUsersList(@RequestBody PageDto<IncomeProofApplicationsAndUsersDto> pageDto) {
        System.out.println(pageDto.getData());
        PageVo<IncomeProofApplicationsAndUsers> incomeProofApplicationsAndUsersPageVo = desktopService.queryIncomeProofApplicationsAndUsers(pageDto);
        return Result.success(incomeProofApplicationsAndUsersPageVo);
    }
    @Operation(summary = "待处理任务-用车申请分页查询")
    @PostMapping("/queryVehicleUsageAndVehicleManagementAndUsersList")
    public Result queryVehicleUsageAndVehicleManagementAndUsersList(@RequestBody PageDto<VehicleUsageAndVehicleManagementAndUsersDto> pageDto) {
        System.out.println(pageDto.getData());
        PageVo<VehicleUsageAndVehicleManagementAndUsers> vehicleUsageAndVehicleManagementAndUsersPageVo = desktopService.queryVehicleUsageAndVehicleManagementAndUsers(pageDto);
        return Result.success(vehicleUsageAndVehicleManagementAndUsersPageVo);
    }
    @Operation(summary = "待处理任务-用章申请分页查询")
    @PostMapping("/querySealManagementList")
    public Result querySealManagementList(@RequestBody PageDto<SealManagementDto> pageDto) {
        System.out.println(pageDto.getData());
        PageVo<SealManagement> sealManagementPageVo = desktopService.querySealManagement(pageDto);
        return Result.success(sealManagementPageVo);
    }
    @Operation(summary = "待处理任务-图书预约申请分页查询")
    @PostMapping("/queryBookBorrowingList")
    public Result queryBookBorrowingList(@RequestBody PageDto<BookBorrowingDto> pageDto) {
        System.out.println(pageDto.getData());
        PageVo<BookBorrowing> bookBorrowingPageVo = desktopService.queryBookBorrowing(pageDto);
        return Result.success(bookBorrowingPageVo);
    }
    @Operation(summary = "待处理任务-名片打印申请分页查询")
    @PostMapping("/queryBusinessCardPrintingList")
    public Result queryBusinessCardPrintingList(@RequestBody PageDto<BusinessCardPrintingDto> pageDto) {
        System.out.println(pageDto.getData());
        PageVo<BusinessCardPrinting> businessCardPrintingPageVo = desktopService.queryBusinessCardPrinting(pageDto);
        return Result.success(businessCardPrintingPageVo);
    }






    /**
     * 获取 红点待处理 个数
     */
    @Operation(summary = "待处理任务-请假待处理个数")
    @GetMapping("/countLeave")
    public Integer countLeave(){
        return  desktopService.countLeave();
    }
    @GetMapping("/countT")
    @Operation(summary = "待处理任务-出差待处理个数")
    public Integer countT(){
        return  desktopService.countT();
    }
    @Operation(summary = "待处理任务-收入待处理个数")
    @GetMapping("/countIncomeProof")
    public Integer countIncomeProof(){
        return desktopService.countIncomeProof();
    }
    @Operation(summary = "待处理任务-用车待处理个数")
    @GetMapping("/countVehicleUsageAndVehicle")
    public Integer countVehicleUsageAndVehicle(){
        return desktopService.countVehicleUsageAndVehicle();
    }
    @Operation(summary = "待处理任务-用章待处理个数")
    @GetMapping("/countSealManagement")
    public Integer countSealManagement(){
        return desktopService.countSealManagement();
    }
    @Operation(summary = "待处理任务-图书待处理个数")
    @GetMapping("/countBookBorrowing")
    public Integer countBookBorrowing(){
        return desktopService.countBookBorrowing();
    }
    @Operation(summary = "待处理任务-名片待处理个数")
    @GetMapping("/countBusinessCar")
    public Integer countBusinessCar(){
        return desktopService.countBusinessCar();
    }






    /**
     *  根据id查看对应显示的修改信息
     */
    @Operation(summary = "根据id查看修改信息_请假")
    @GetMapping("/LookUpdateLeaveApplicationsAndUsersList/{applicationId}")
    public LeaveApplicationsAndUsersVo LookUpdateLeaveApplicationsAndUsersList(@PathVariable Integer applicationId) {
        return desktopService.LookUpdateLeaveApplicationsAndUsersList(applicationId);
    }
    @Operation(summary = "根据id查看修改信息_出差")
    @GetMapping("/LookUpdateTravelApplicationsAndUsersList/{applicationId}")
    public TravelApplicationsAndUsers LookUpdateTravelApplicationsAndUsersList(@PathVariable Integer applicationId) {
        return desktopService.LookUpdateTravelApplicationsAndUsersList(applicationId);
    }
    @Operation(summary = "根据id查看修改信息_收入")
    @GetMapping("/LookUpdateIncomeProofApplicationsAndUsersList/{applicationId}")
    public IncomeProofApplicationsAndUsers LookUpdateIncomeProofApplicationsAndUsersList(@PathVariable Integer applicationId) {
        return desktopService.LookUpdateIncomeProofApplicationsAndUsersList(applicationId);
    }
    @Operation(summary = "根据id查看修改信息_用车")
    @GetMapping("/LookUpdateVehicleUsageAndVehicleManagementAndUsers/{usageId}")
    public VehicleUsageAndVehicleManagementAndUsers LookUpdateVehicleUsageAndVehicleManagementAndUsers(@PathVariable Integer usageId) {
        return desktopService.LookUpdateVehicleUsageAndVehicleManagementAndUsers(usageId);
    }
    @Operation(summary = "根据id查看修改信息_用章")
    @GetMapping("/LookUpdateSealManagementList/{id}")
    public SealManagement LookUpdateSealManagementList(@PathVariable Integer id) {
        return desktopService.LookUpdateSealManagementList(id);
    }
    @Operation(summary = "根据id查看修改信息_图书")
    @GetMapping("/LookUpdateBookBorrowingList/{id}")
    public BookBorrowing LookUpdateBookBorrowingList(@PathVariable Integer id) {
        return desktopService.LookUpdateBookBorrowingList(id);
    }
    @Operation(summary = "根据id查看修改信息_名片")
    @GetMapping("/LookUpdateBusinessCardPrintingList/{id}")
    public BusinessCardPrinting LookUpdateBusinessCardPrintingList(@PathVariable Integer id) {
        return desktopService.LookUpdateBusinessCardPrintingList(id);
    }






    /**
     * 审核 修改信息操作，传入需要进行修改的对象
     */
    @Operation(summary = "待处理任务_审核修改-请假")
    @PutMapping("/UpdateStatusLeaveApplicationsAndUsersList")
    public Result UpdateStatusLeaveApplicationsAndUsersList(@RequestBody LeaveApplicationsAndUsersVo leaveApplicationsAndUsersVo) {
        System.out.println("待处理任务_审核修改-请假====》》》"+leaveApplicationsAndUsersVo);
        desktopService.UpdateStatusLeaveApplicationsAndUsersList(leaveApplicationsAndUsersVo);
        return Result.success();
    }






    @Operation(summary = "我的便签_查询所有显示")
    @GetMapping("/desktopAll/{userId}")
    public Result DesktopAll(@PathVariable Integer userId) {
        List<Notes> list = desktopService.getNotesList(userId);
        return Result.success(list);
    }

    @Operation(summary = "通告管理-首页查询所有")
    @GetMapping("/announcementsAll")
    public Result AnnouncementsAll() {
        List<Announcements> list = desktopService.getAnnouncementsList();
        return Result.success(list);
    }

    @Operation(summary = "待处理任务-请假申请查询所有")
    @GetMapping("/leaveApplicationsAll")
    public Result leaveApplicationsAll() {
        List<LeaveApplicationsAndUsersVo> list = desktopService.getLeaveApplicationsAndUsersList();
        return Result.success(list);
    }
    @Operation(summary = "待处理任务-出差申请查询所有")
    @GetMapping("/travelApplicationsAll")
    public Result travelApplicationsAll() {
        List<TravelApplicationsAndUsers> list = desktopService.getTravelApplicationsAndUsersList();
        return Result.success(list);
    }
    @Operation(summary = "待处理任务-收入证明流程查询所有")
    @GetMapping("/incomeProofApplicationsAll")
    public Result incomeProofApplicationsAll() {
        List<IncomeProofApplicationsAndUsers> list = desktopService.getIncomeProofApplicationsAndUsersList();
        return Result.success(list);
    }
    @Operation(summary = "待处理任务-用车申请查询所有")
    @GetMapping("/vehicleUsageAndVehicleManagementAndUsersAll")
    public Result VehicleUsageAndVehicleManagementAndUsersAll() {
        List<VehicleUsageAndVehicleManagementAndUsers> list = desktopService.getVehicleUsageAndVehicleManagementAndUsers();
        return Result.success(list);
    }
    @Operation(summary = "待处理任务-用章申请查询所有")
    @GetMapping("/sealManagementAll")
    public Result SealManagementList() {
        List<SealManagement> list = desktopService.getSealManagementList();
        return Result.success(list);
    }
    @Operation(summary = "待处理任务-图书申请查询所有")
    @GetMapping("/bookBorrowingAll")
    public Result BookBorrowingList() {
        List<BookBorrowing> list = desktopService.getBookBorrowingList();
        return Result.success(list);
    }
    @Operation(summary = "待处理任务-名片印制查询所有")
    @GetMapping("/businessCardPrintingAll")
    public Result BusinessCardPrintingList() {
        List<BusinessCardPrinting> list = desktopService.getBusinessCardPrintingList();
        return Result.success(list);
    }






    @Operation(summary = "我的便签新增")
    @PostMapping("/desktopAdd")
    public Result DesktopAdd(@RequestBody Notes notes) {
        System.out.println("便签添加获取数据"+notes.toString());
        System.out.println("我的便签获取新增数据"+notes);
        desktopService.addNotes(notes);
        return Result.success();
    }
    @Operation(summary = "我的便签_删除")
    @DeleteMapping("/desktopDel/{noteId}")
    public Result DesktopDel(@PathVariable Integer noteId) {
        desktopService.deleteNotes(noteId);
        return Result.success();
    }
    @Operation(summary = "我的便签_修改")
    @PutMapping("/desktopUpd")
    public Result DesktopUpds(@RequestBody Notes notes){
        desktopService.updateNotes(notes);
        return Result.success();
    }
}
